<?php

namespace Addons\Zmphoto\Model;
use Think\Model;

/**
 * Zmphoto模型
 */
class PublicModel extends Model{

    //获取记录集
    public function getListAll($field='',$where=null,$join=false,$order='id'){
        if(empty($where['status']))$where['status'] = 1;
                                   $where['token']  = get_token();
        return $this->join($join)->where($where)->field($field)->order($order)->select();
    }

    //获取单条记录
    public function getOne($where,$field='',$join=false){
        if(empty($where['status']))$where['status'] = 1;
                                   $where['token']  = get_token();
        return $this->join($join)->where($where)->field($field)->find();
    }

    //获取字段
    public function getFie($where,$field){
      if(empty($where['status']))$where['status'] = 1;
                                 $where['token']  = get_token();
      return $this->where($where)->getField($field);
    }


    //数据更新
    public function update($where,$data){
       $data['update_time'] = time();
       $ok = $this->where($where)->save($data);
       return  $ok;
    }

    /*添加数据*/
    public function addData($data){
      $data['token'] = get_token();
      $data['create_time'] = time();
      return $this->add($data);
    }

}
